home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / SoundSprocket / SoundSprocketTest Sources / TS3TestLoLevel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-26  |  45.9 KB  |  1,774 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    File:        TS3TestLoLevel.c
  3.  *
  4.  *    Copyright © 1996 Apple Computer, Inc.
  5.  */
  6.  
  7. #include <assert.h>
  8. #include <math.h>
  9. #include <string.h>
  10.  
  11. #include <Dialogs.h>
  12. #include <Fonts.h>
  13. #include <Menus.h>
  14. #include <Timer.h>
  15.  
  16. #include "TS3Menu.h"
  17. #include "TS3Message.h"
  18. #include "TS3Resource.h"
  19. #include "TS3Sound.h"
  20. #include "TS3TestLoLevel.h"
  21. #include "TS3Utils.h"
  22. #include "TS3Window.h"
  23.  
  24. #include "SoundSprocket.h"
  25.  
  26.  
  27. typedef struct TTestLoLevelData {
  28.     float            duration;
  29.     
  30.     UInt32            cpuLoad1;
  31.     UInt32            cpuLoad2;
  32.     Boolean            cpuLoadRange;
  33.     
  34.     UInt32            medium;
  35.     
  36.     float            humidity1;
  37.     float            humidity2;
  38.     Boolean            humidityRange;
  39.     
  40.     float            roomSize1;
  41.     float            roomSize2;
  42.     Boolean            roomSizeRange;
  43.     
  44.     float            roomReflectivity1;
  45.     float            roomReflectivity2;
  46.     Boolean            roomReflectivityRange;
  47.     
  48.     float            reverbAttenuation1;
  49.     float            reverbAttenuation2;
  50.     Boolean            reverbAttenuationRange;
  51.     
  52.     UInt32            sourceMode;
  53.     
  54.     float            referenceDistance1;
  55.     float            referenceDistance2;
  56.     Boolean            referenceDistanceRange;
  57.     
  58.     float            coneAngleDeg1;
  59.     float            coneAngleDeg2;
  60.     Boolean            coneAngleDegRange;
  61.     
  62.     float            coneAttenuation1;
  63.     float            coneAttenuation2;
  64.     Boolean            coneAttenuationRange;
  65.     
  66.     float            elevationDeg1;
  67.     float            elevationDeg2;
  68.     Boolean            elevationDegRange;
  69.     
  70.     float            azimuthDeg1;
  71.     float            azimuthDeg2;
  72.     Boolean            azimuthDegRange;
  73.     
  74.     float            distance1;
  75.     float            distance2;
  76.     Boolean            distanceRange;
  77.     
  78.     float            projectionAngleDeg1;
  79.     float            projectionAngleDeg2;
  80.     Boolean            projectionAngleDegRange;
  81.     
  82.     float            sourceVelocity1;
  83.     float            sourceVelocity2;
  84.     Boolean            sourceVelocityRange;
  85.     
  86.     float            listenerVelocity1;
  87.     float            listenerVelocity2;
  88.     Boolean            listenerVelocityRange;
  89.     
  90.     float            coneAngleCos1;
  91.     float            coneAngleCos2;
  92.     
  93.     float            elevation1;
  94.     float            elevation2;
  95.     
  96.     float            azimuth1;
  97.     float            azimuth2;
  98.     
  99.     float            projectionAngle1;
  100.     float            projectionAngle2;
  101. } TTestLoLevelData;
  102.  
  103.  
  104. static MenuHandle                gTestLoLevelPresetMenu            = NULL;
  105. static DialogPtr                gTestLoLevelDialog                = NULL;
  106. static UserItemUPP                gTestLoLevelProgressUserItem    = NULL;
  107. static UInt32                    gTestLoLevelCPULoadLimit;
  108. static TTestLoLevelData            gTestLoLevelData;
  109.  
  110. static UnsignedWide                gTestLoLevelCycleStart;
  111. static float                    gTestLoLevelInterpolant            = 0.0;
  112.  
  113.  
  114. static WindowMethodPtr TestLoLevel_MetaHandler(
  115.     WindowMethod        inMethod);
  116.  
  117. static void TestLoLevel_GetSleep(
  118.     WindowPtr            inWindow,
  119.     UInt32*                outSleep);
  120.  
  121. static void TestLoLevel_ConsumeEvent(
  122.     WindowPtr            inWindow,
  123.     const EventRecord*    inEvent,
  124.     Boolean*            outConsumed);
  125.  
  126. static void TestLoLevel_Update(
  127.     WindowPtr            inWindow);
  128.  
  129. static void TestLoLevel_Activate(
  130.     WindowPtr            inWindow);
  131.  
  132. static void TestLoLevel_Deactivate(
  133.     WindowPtr            inWindow);
  134.  
  135. static pascal void TestLoLevel_ProgressUserItem(
  136.     DialogPtr            inDialog,
  137.     short                inItem);
  138.  
  139. static void TestLoLevel_Interpolate(
  140.     void);
  141.  
  142. static float TestLoLevel_DoInterpolate(
  143.     float                inWhere,
  144.     float                inVal0,
  145.     float                inVal1,
  146.     Boolean                inIsRange);
  147.  
  148. static void TestLoLevel_DeriveData(
  149.     void);
  150.  
  151. static void TestLoLevel_SetDialogFields(
  152.     void);
  153.  
  154. static void TestLoLevel_GetDialogFields(
  155.     void);
  156.  
  157.  
  158. /* =============================================================================
  159.  *        TestLoLevel_Init (external)
  160.  *
  161.  *    Initializes our thing.
  162.  * ========================================================================== */
  163. void TestLoLevel_Init(
  164.     void)
  165. {
  166.     OSStatus            err;
  167.     TEHandle            textEdit;
  168.     FontInfo            fontInfo;
  169.     short                itemType;
  170.     Handle                itemHandle;
  171.     Rect                itemBounds;
  172.     Str255                str;
  173.     
  174.     // Make sure we didn't mess up the dialog items
  175.     assert(kLoLevelItem_COUNT == kLoLevelItem_ExpectedCOUNT);
  176.     
  177.     // Grab the maximum CPU load limit value
  178.     gTestLoLevelCPULoadLimit = 999;
  179.     err = SSpGetCPULoadLimit(&gTestLoLevelCPULoadLimit);
  180.     Message_CheckError(err, "TestLoLevel_Init", "SSpGetCPULoadLimit");
  181.     
  182.     //• TODO: Read in gTestLoLevelData from preferences
  183.     
  184.     // Grab the menu
  185.     gTestLoLevelPresetMenu = GetMenu(kMenuID_LoLevelPreset);
  186.     
  187.     // Grab the dialog
  188.     gTestLoLevelDialog = GetNewDialog(kDlogID_LoLevel, NULL, (WindowPtr) -1);
  189.     assert(gTestLoLevelDialog != NULL);
  190.     
  191.     SetPort(gTestLoLevelDialog);
  192.     TextFont(geneva);
  193.     TextSize(10);
  194.     
  195.     // Fix up the line height
  196.     GetFontInfo(&fontInfo);
  197.     
  198.     textEdit = ((DialogPeek) gTestLoLevelDialog)->textH;
  199.     
  200.     (*textEdit)->lineHeight = fontInfo.ascent+fontInfo.descent+fontInfo.leading;
  201.     (*textEdit)->fontAscent = fontInfo.ascent;
  202.     
  203.     // Set up our method table
  204.     Window_New(gTestLoLevelDialog, TestLoLevel_MetaHandler);
  205.     
  206.     // Do the user items
  207.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_UpdateHilite, &itemType, &itemHandle, &itemBounds);
  208.     SetDialogItem(gTestLoLevelDialog, kLoLevelItem_UpdateHilite, itemType, (Handle) Utils_GetOKUserItemProc(), &itemBounds);
  209.     
  210.     gTestLoLevelProgressUserItem = NewUserItemProc(TestLoLevel_ProgressUserItem);
  211.     assert(gTestLoLevelProgressUserItem != NULL);
  212.     
  213.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_Progress, &itemType, &itemHandle, &itemBounds);
  214.     SetDialogItem(gTestLoLevelDialog, kLoLevelItem_Progress, itemType, (Handle) gTestLoLevelProgressUserItem, &itemBounds);
  215.     
  216.     // Show the quality limit
  217.     sprintf((char*) str, "x[0..%ld]", gTestLoLevelCPULoadLimit);
  218.     str[0] = strlen((char*) str)-1;
  219.     
  220.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_CPULoadUnits, &itemType, &itemHandle, &itemBounds);
  221.     SetDialogItemText(itemHandle, str);
  222.     
  223.     // Set the initial field values
  224.     TestLoLevel_Preset(1);
  225.     
  226.     // Select the first field
  227.     SelectDialogItemText(gTestLoLevelDialog, kLoLevelItem_Duration, 0, 32767);
  228.     
  229.     // Show the dialog
  230.     ShowWindow(gTestLoLevelDialog);
  231.     
  232.     // Initialize our cycle timer
  233.     Microseconds(&gTestLoLevelCycleStart);
  234. }
  235.  
  236.  
  237. /* =============================================================================
  238.  *        TestLoLevel_Exit (external)
  239.  *
  240.  *    Cleans up.
  241.  * ========================================================================== */
  242. void TestLoLevel_Exit(
  243.     void)
  244. {
  245.     //• TODO: Save gTestLoLevel to preferences
  246.     
  247.     if (gTestLoLevelDialog != NULL)
  248.     {
  249.         DisposeDialog(gTestLoLevelDialog);
  250.         gTestLoLevelDialog = NULL;
  251.     }
  252.     
  253.     if (gTestLoLevelProgressUserItem != NULL)
  254.     {
  255.         DisposeRoutineDescriptor(gTestLoLevelProgressUserItem);
  256.         gTestLoLevelProgressUserItem = NULL;
  257.     }
  258. }
  259.  
  260.  
  261. /* =============================================================================
  262.  *        TestLoLevel_MetaHandler (internal)
  263.  *
  264.  *    Returns the method function pointer that corresponds to the given ID.
  265.  * ========================================================================== */
  266. WindowMethodPtr TestLoLevel_MetaHandler(
  267.     WindowMethod        inMethod)
  268. {
  269.     WindowMethodPtr        result;
  270.     
  271.     result = NULL;
  272.     
  273.     switch (inMethod)
  274.     {
  275.         case kWindowMethod_GetSleep:
  276.             result = (WindowMethodPtr) TestLoLevel_GetSleep;
  277.         break;
  278.         
  279.         case kWindowMethod_ConsumeEvent:
  280.             result = (WindowMethodPtr) TestLoLevel_ConsumeEvent;
  281.         break;
  282.         
  283.         case kWindowMethod_Update:
  284.             result = (WindowMethodPtr) TestLoLevel_Update;
  285.         break;
  286.         
  287.         case kWindowMethod_Activate:
  288.             result = (WindowMethodPtr) TestLoLevel_Activate;
  289.         break;
  290.         
  291.         case kWindowMethod_Deactivate:
  292.             result = (WindowMethodPtr) TestLoLevel_Deactivate;
  293.         break;
  294.     }
  295.     
  296.     return result;
  297. }
  298.  
  299.  
  300. /* =============================================================================
  301.  *        TestLoLevel_GetSleep (internal)
  302.  *
  303.  *    Returns the sleep time to pass to WaitNextEvent when we're in front.
  304.  * ========================================================================== */
  305. void TestLoLevel_GetSleep(
  306.     WindowPtr            inWindow,
  307.     UInt32*                outSleep)
  308. {
  309.     assert(outSleep != NULL);
  310.     
  311.     *outSleep = 0;
  312. }
  313.  
  314.  
  315. /* =============================================================================
  316.  *        TestLoLevel_ConsumeEvent (internal)
  317.  *
  318.  *    Called for each event when this is the front window.
  319.  * ========================================================================== */
  320. void TestLoLevel_ConsumeEvent(
  321.     WindowPtr            inWindow,
  322.     const EventRecord*    inEvent,
  323.     Boolean*            outConsumed)
  324. {
  325.     short                itemType;
  326.     Handle                itemHandle;
  327.     Rect                itemBounds;
  328.     ControlHandle        updateButton;
  329.     Boolean                consumed;
  330.     Boolean                passToDialog;
  331.     WindowPtr            window;
  332.     short                item;
  333.     unsigned long        timeout;
  334.     UnsignedWide        now;
  335.     
  336.     assert(inEvent != NULL);
  337.     assert(outConsumed != NULL);
  338.     
  339.     consumed = false;
  340.     passToDialog = true;
  341.     
  342.     // We want to handle some events ourself
  343.     switch (inEvent->what)
  344.     {
  345.         case keyDown:
  346.         case autoKey:
  347.             passToDialog = false;
  348.             
  349.             if (inEvent->modifiers & cmdKey)
  350.             {
  351.                 if (inEvent->what != autoKey)
  352.                 {
  353.                     switch (inEvent->message & charCodeMask)
  354.                     {
  355.                         case '.':
  356.                             // anything here?
  357.                         break;
  358.                     }
  359.                 }
  360.             }
  361.             else
  362.             {
  363.                 switch (inEvent->message & charCodeMask)
  364.                 {
  365.                     case 0x08:  // backspace
  366.                     case 0x09:  // tab
  367.                     case 0x1C:  // cursor left
  368.                     case 0x1D:  // cursor right
  369.                     case 0x1E:  // cursor up
  370.                     case 0x1F:  // cursor down
  371.                     case '.':
  372.                     case '-':
  373.                     case '0':
  374.                     case '1':
  375.                     case '2':
  376.                     case '3':
  377.                     case '4':
  378.                     case '5':
  379.                     case '6':
  380.                     case '7':
  381.                     case '8':
  382.                     case '9':
  383.                         // Pass it to the dialog
  384.                         passToDialog = true;
  385.                     break;
  386.                     
  387.                     case 0x03:  // enter
  388.                     case 0x0D:  // return
  389.                         if (inEvent->what != autoKey)
  390.                         {
  391.                             // Update button equivalent
  392.                             GetDialogItem(gTestLoLevelDialog, kLoLevelItem_Update, &itemType, &itemHandle, &itemBounds);
  393.                             updateButton = (ControlHandle) itemHandle;
  394.                             
  395.                             if ((*updateButton)->contrlHilite == 0)
  396.                             {
  397.                                 HiliteControl(updateButton, 1);
  398.                                 
  399.                                 timeout = TickCount()+6;
  400.                                 while (TickCount() < timeout) /* wait */;
  401.                                 
  402.                                 HiliteControl(updateButton, 0);
  403.                                 
  404.                                 TestLoLevel_GetDialogFields();
  405.                                 
  406.                                 consumed = true;
  407.                             }
  408.                         }
  409.                     break;
  410.                     
  411.                     default:
  412.                         SysBeep(10);
  413.                         consumed = true;
  414.                 }
  415.             }
  416.         break;
  417.         
  418.         case activateEvt:
  419.             // We need to look at the activate event here because it is
  420.             // consumed by IsDialogEvent/DialogSelect below and so never
  421.             // gets to the window stuff
  422.             window = (WindowPtr) inEvent->message;
  423.             
  424.             if (inEvent->modifiers & activeFlag)
  425.             {
  426.                 Window_Activate(window);
  427.             }
  428.             else
  429.             {
  430.                 Window_Deactivate(window);
  431.             }
  432.         break;
  433.         
  434.         case nullEvent:
  435.             // Find where we are in the cycle (0 is start, 1 is end)
  436.             Microseconds(&now);
  437.             gTestLoLevelInterpolant = Utils_Interval(&gTestLoLevelCycleStart, &now) / gTestLoLevelData.duration;
  438.             
  439.             switch (Menu_GetInterpolation())
  440.             {
  441.                 case kInterpolationItem_Sinusoidal:
  442.                     gTestLoLevelInterpolant = 0.5*sinf(gTestLoLevelInterpolant*_PI*2.0) + 0.5;
  443.                 break;
  444.                 
  445.                 case kInterpolationItem_Triangular:
  446.                     gTestLoLevelInterpolant = 2.0*fmodf(gTestLoLevelInterpolant, 1.0);
  447.                     
  448.                     if (gTestLoLevelInterpolant > 1.0)
  449.                     {
  450.                         gTestLoLevelInterpolant = 2.0-gTestLoLevelInterpolant;
  451.                     }
  452.                 break;
  453.                 
  454.                 case kInterpolationItem_Sawtooth:
  455.                     gTestLoLevelInterpolant = fmodf(2.0*gTestLoLevelInterpolant, 1.0);
  456.                 break;
  457.             }
  458.             
  459.             TestLoLevel_Interpolate();
  460.         break;
  461.     }
  462.     
  463.     // Do dialog stuff
  464.     if (passToDialog)
  465.     {
  466.         consumed = IsDialogEvent(inEvent);
  467.         if (consumed)
  468.         {
  469.             if (DialogSelect(inEvent, &window, &item))
  470.             {
  471.                 switch (item)
  472.                 {
  473.                     case kLoLevelItem_Update:
  474.                         TestLoLevel_GetDialogFields();
  475.                     break;
  476.                 }
  477.             }
  478.         }
  479.     }
  480.     
  481.     // Return the result
  482.     *outConsumed = consumed;
  483. }
  484.  
  485.  
  486. /* =============================================================================
  487.  *        TestLoLevel_Update (internal)
  488.  *
  489.  *    Updates the contents of the window.
  490.  * ========================================================================== */
  491. void TestLoLevel_Update(
  492.     WindowPtr            inWindow)
  493. {
  494.     DrawDialog(inWindow);
  495. }
  496.  
  497.  
  498. /* =============================================================================
  499.  *        TestLoLevel_Activate (internal)
  500.  *
  501.  *    Handles window activation.
  502.  * ========================================================================== */
  503. void TestLoLevel_Activate(
  504.     WindowPtr            inWindow)
  505. {
  506.     InsertMenu(gTestLoLevelPresetMenu, 0);
  507.     DrawMenuBar();
  508. }
  509.  
  510.  
  511. /* =============================================================================
  512.  *        TestLoLevel_Deactivate (internal)
  513.  *
  514.  *    Handles window deactivation.
  515.  * ========================================================================== */
  516. void TestLoLevel_Deactivate(
  517.     WindowPtr            inWindow)
  518. {
  519.     DeleteMenu(kMenuID_LoLevelPreset);
  520.     DrawMenuBar();
  521. }
  522.  
  523.  
  524. /* =============================================================================
  525.  *        TestLoLevel_ProgressUserItem (internal)
  526.  *
  527.  *    Draws the user item used for progress bar, based on gTestLoLevelInterpolant.
  528.  * ========================================================================== */
  529. pascal void TestLoLevel_ProgressUserItem(
  530.     DialogPtr            inDialog,
  531.     short                inItem)
  532. {
  533.     short                itemType;
  534.     Handle                itemHandle;
  535.     Rect                itemBounds;
  536.     short                size;
  537.     Rect                leftWhite;
  538.     Rect                rightWhite;
  539.     Rect                indicator;
  540.     
  541.     GetDialogItem(inDialog, inItem, &itemType, &itemHandle, &itemBounds);
  542.     
  543.     FrameRect(&itemBounds);
  544.     
  545.     InsetRect(&itemBounds, 1, 1);
  546.     size = itemBounds.bottom-itemBounds.top;
  547.     
  548.     indicator = itemBounds;
  549.     indicator.left = itemBounds.left + (long) (gTestLoLevelInterpolant*(itemBounds.right-itemBounds.left-size) + 0.5);
  550.     indicator.right = indicator.left+size;
  551.     
  552.     leftWhite = itemBounds;
  553.     leftWhite.right = indicator.left;
  554.     
  555.     rightWhite = itemBounds;
  556.     rightWhite.left = indicator.right;
  557.     
  558.     FrameRect(&indicator);
  559.     
  560.     InsetRect(&indicator, 1, 1);
  561.     FillRect(&indicator, &qd.gray);
  562.     
  563.     EraseRect(&leftWhite);
  564.     EraseRect(&rightWhite);
  565. }
  566.  
  567.  
  568. /* =============================================================================
  569.  *        TestLoLevel_Interpolate (internal)
  570.  *
  571.  *    Changes the sound channel to the correct values for the point between
  572.  *    zero and one determined by gTestLoLevelInterpolant.
  573.  * ========================================================================== */
  574. void TestLoLevel_Interpolate(
  575.     void)
  576. {
  577.     SSpLocalizationData            snd3DInfo;
  578.     float                        elevation;
  579.     float                        azimuth;
  580.     
  581.     snd3DInfo.cpuLoad = (UInt32) (TestLoLevel_DoInterpolate(
  582.             gTestLoLevelInterpolant,
  583.             (float) gTestLoLevelData.cpuLoad1,
  584.             (float) gTestLoLevelData.cpuLoad2,
  585.             gTestLoLevelData.cpuLoadRange) + 0.5);
  586.     
  587.     snd3DInfo.medium = gTestLoLevelData.medium;
  588.     
  589.     snd3DInfo.humidity = TestLoLevel_DoInterpolate(
  590.             gTestLoLevelInterpolant,
  591.             gTestLoLevelData.humidity1,
  592.             gTestLoLevelData.humidity2,
  593.             gTestLoLevelData.humidityRange);
  594.     
  595.     snd3DInfo.roomSize = TestLoLevel_DoInterpolate(
  596.             gTestLoLevelInterpolant,
  597.             gTestLoLevelData.roomSize1,
  598.             gTestLoLevelData.roomSize2,
  599.             gTestLoLevelData.roomSizeRange);
  600.     
  601.     snd3DInfo.roomReflectivity = TestLoLevel_DoInterpolate(
  602.             gTestLoLevelInterpolant,
  603.             gTestLoLevelData.roomReflectivity1,
  604.             gTestLoLevelData.roomReflectivity2,
  605.             gTestLoLevelData.roomReflectivityRange);
  606.     
  607.     snd3DInfo.reverbAttenuation = TestLoLevel_DoInterpolate(
  608.             gTestLoLevelInterpolant,
  609.             gTestLoLevelData.reverbAttenuation1,
  610.             gTestLoLevelData.reverbAttenuation2,
  611.             gTestLoLevelData.reverbAttenuationRange);
  612.     
  613.     snd3DInfo.sourceMode = gTestLoLevelData.sourceMode;
  614.     
  615.     snd3DInfo.referenceDistance = TestLoLevel_DoInterpolate(
  616.             gTestLoLevelInterpolant,
  617.             gTestLoLevelData.referenceDistance1,
  618.             gTestLoLevelData.referenceDistance2,
  619.             gTestLoLevelData.referenceDistanceRange);
  620.     
  621.     snd3DInfo.coneAngleCos = TestLoLevel_DoInterpolate(
  622.             gTestLoLevelInterpolant,
  623.             gTestLoLevelData.coneAngleCos1,
  624.             gTestLoLevelData.coneAngleCos2,
  625.             gTestLoLevelData.coneAngleDegRange);
  626.     
  627.     snd3DInfo.coneAttenuation = TestLoLevel_DoInterpolate(
  628.             gTestLoLevelInterpolant,
  629.             gTestLoLevelData.coneAttenuation1,
  630.             gTestLoLevelData.coneAttenuation2,
  631.             gTestLoLevelData.coneAttenuationRange);
  632.     
  633.     // Wrap the azimuth and elevation to fit in their ranges
  634.     elevation = TestLoLevel_DoInterpolate(
  635.             gTestLoLevelInterpolant,
  636.             gTestLoLevelData.elevation1,
  637.             gTestLoLevelData.elevation2,
  638.             gTestLoLevelData.elevationDegRange);
  639.     
  640.     azimuth = TestLoLevel_DoInterpolate(
  641.             gTestLoLevelInterpolant,
  642.             gTestLoLevelData.azimuth1,
  643.             gTestLoLevelData.azimuth2,
  644.             gTestLoLevelData.azimuthDegRange);
  645.     
  646.     // find azimuth in the range -2π..2π
  647.     azimuth = fmodf(azimuth, 2.0*_PI);
  648.     
  649.     // find azimuth in the range -π..π
  650.     if (azimuth < -_PI)
  651.     {
  652.         azimuth += 2.0*_PI;
  653.     }
  654.     else if (azimuth > _PI)
  655.     {
  656.         azimuth -= 2.0*_PI;
  657.     }
  658.     
  659.     // find azimuth in the range -π/2..π/2
  660.     if (azimuth < -0.5*_PI)
  661.     {
  662.         azimuth = -_PI-azimuth;
  663.         elevation -= _PI;
  664.     }
  665.     else if (azimuth > 0.5*_PI)
  666.     {
  667.         azimuth = _PI-azimuth;
  668.         elevation -= _PI;
  669.     }
  670.     
  671.     // find elevation in the range -2π..2π
  672.     elevation = fmodf(elevation, 2.0*_PI);
  673.     
  674.     // find elevation in the range -π..π
  675.     if (elevation < -_PI)
  676.     {
  677.         elevation += 2.0*_PI;
  678.     }
  679.     else if (elevation > _PI)
  680.     {
  681.         elevation -= 2.0*_PI;
  682.     }
  683.     
  684.     snd3DInfo.currentLocation.elevation = elevation;
  685.     snd3DInfo.currentLocation.azimuth = azimuth;
  686.     
  687.     snd3DInfo.currentLocation.distance = TestLoLevel_DoInterpolate(
  688.             gTestLoLevelInterpolant,
  689.             gTestLoLevelData.distance1,
  690.             gTestLoLevelData.distance2,
  691.             gTestLoLevelData.distanceRange);
  692.     
  693.     snd3DInfo.currentLocation.projectionAngle = TestLoLevel_DoInterpolate(
  694.             gTestLoLevelInterpolant,
  695.             gTestLoLevelData.projectionAngle1,
  696.             gTestLoLevelData.projectionAngle2,
  697.             gTestLoLevelData.projectionAngleDegRange);
  698.     
  699.     snd3DInfo.currentLocation.sourceVelocity = TestLoLevel_DoInterpolate(
  700.             gTestLoLevelInterpolant,
  701.             gTestLoLevelData.sourceVelocity1,
  702.             gTestLoLevelData.sourceVelocity2,
  703.             gTestLoLevelData.sourceVelocityRange);
  704.     
  705.     snd3DInfo.currentLocation.listenerVelocity = TestLoLevel_DoInterpolate(
  706.             gTestLoLevelInterpolant,
  707.             gTestLoLevelData.listenerVelocity1,
  708.             gTestLoLevelData.listenerVelocity2,
  709.             gTestLoLevelData.listenerVelocityRange);
  710.     
  711.     snd3DInfo.reserved0 = 0;
  712.     snd3DInfo.reserved1 = 0;
  713.     snd3DInfo.reserved2 = 0;
  714.     snd3DInfo.reserved3 = 0;
  715.     
  716.     snd3DInfo.virtualSourceCount = 0;
  717.     
  718.     // Make the filter changes
  719.     Sound_Set3DInfo(&snd3DInfo);
  720.     
  721.     // Update the progress bar
  722.     SetPort(gTestLoLevelDialog);
  723.     TestLoLevel_ProgressUserItem(gTestLoLevelDialog, kLoLevelItem_Progress);
  724. }
  725.  
  726.  
  727. /* =============================================================================
  728.  *        TestLoLevel_DoInterpolate (internal)
  729.  *
  730.  *    Linear interpolation.  When inWhere is zero, inVal0 is returned.  When it
  731.  *    is one, inVal1 is returned.  In between is linear.  If inIsRange is false
  732.  *    then we ignore inVal1 and always return inVal0.
  733.  * ========================================================================== */
  734. float TestLoLevel_DoInterpolate(
  735.     float                inWhere,
  736.     float                inVal0,
  737.     float                inVal1,
  738.     Boolean                inIsRange)
  739. {
  740.     float                result;
  741.     
  742.     if (inIsRange)
  743.     {
  744.         result = inWhere*(inVal1-inVal0) + inVal0;
  745.     }
  746.     else
  747.     {
  748.         result = inVal0;
  749.     }
  750.     
  751.     return result;
  752. }
  753.  
  754.  
  755. /* =============================================================================
  756.  *        TestLoLevel_DeriveData (internal)
  757.  *
  758.  *    Compute the derived fields in gTestLoLevelData.
  759.  * ========================================================================== */
  760. void TestLoLevel_DeriveData(
  761.     void)
  762. {
  763.     gTestLoLevelData.coneAngleCos1            = cosf(0.5*(_PI/180.0)*gTestLoLevelData.coneAngleDeg1);
  764.     gTestLoLevelData.coneAngleCos2            = cosf(0.5*(_PI/180.0)*gTestLoLevelData.coneAngleDeg2);
  765.     
  766.     gTestLoLevelData.elevation1                = (_PI/180.0)*gTestLoLevelData.elevationDeg1;
  767.     gTestLoLevelData.elevation2                = (_PI/180.0)*gTestLoLevelData.elevationDeg2;
  768.     
  769.     gTestLoLevelData.azimuth1                = (_PI/180.0)*gTestLoLevelData.azimuthDeg1;
  770.     gTestLoLevelData.azimuth2                = (_PI/180.0)*gTestLoLevelData.azimuthDeg2;
  771.     
  772.     gTestLoLevelData.projectionAngle1        = cosf((_PI/180.0)*gTestLoLevelData.projectionAngleDeg1);
  773.     gTestLoLevelData.projectionAngle2        = cosf((_PI/180.0)*gTestLoLevelData.projectionAngleDeg2);
  774. }
  775.  
  776.  
  777. /* =============================================================================
  778.  *        TestLoLevel_SetDialogFields (internal)
  779.  *
  780.  *    Changes the dialog's fields to reflect gTestLoLevelData.
  781.  * ========================================================================== */
  782. void TestLoLevel_SetDialogFields(
  783.     void)
  784. {
  785.     short                itemType;
  786.     Handle                itemHandle;
  787.     Rect                itemBounds;
  788.     short                value;
  789.     
  790.     Utils_SetFloatField(
  791.             gTestLoLevelDialog,
  792.             kLoLevelItem_Duration,
  793.             gTestLoLevelData.duration,
  794.             true);
  795.     
  796.     Utils_SetUInt32Field(
  797.             gTestLoLevelDialog,
  798.             kLoLevelItem_CPULoad1,
  799.             gTestLoLevelData.cpuLoad1,
  800.             true);
  801.     
  802.     Utils_SetUInt32Field(
  803.             gTestLoLevelDialog,
  804.             kLoLevelItem_CPULoad2,
  805.             gTestLoLevelData.cpuLoad2,
  806.             gTestLoLevelData.cpuLoadRange);
  807.     
  808.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_Medium, &itemType, &itemHandle, &itemBounds);
  809.     SetControlValue((ControlHandle) itemHandle,
  810.             (gTestLoLevelData.medium == kSSpMedium_Water)
  811.                     ? kMediumItem_Water
  812.                     : kMediumItem_Air);
  813.     
  814.     Utils_SetFloatField(
  815.             gTestLoLevelDialog,
  816.             kLoLevelItem_Humidity1,
  817.             gTestLoLevelData.humidity1,
  818.             true);
  819.     
  820.     Utils_SetFloatField(
  821.             gTestLoLevelDialog,
  822.             kLoLevelItem_Humidity2,
  823.             gTestLoLevelData.humidity2,
  824.             gTestLoLevelData.humidityRange);
  825.     
  826.     Utils_SetFloatField(
  827.             gTestLoLevelDialog,
  828.             kLoLevelItem_RoomSize1,
  829.             gTestLoLevelData.roomSize1,
  830.             true);
  831.     
  832.     Utils_SetFloatField(
  833.             gTestLoLevelDialog,
  834.             kLoLevelItem_RoomSize2,
  835.             gTestLoLevelData.roomSize2,
  836.             gTestLoLevelData.roomSizeRange);
  837.     
  838.     Utils_SetFloatField(
  839.             gTestLoLevelDialog,
  840.             kLoLevelItem_RoomReflectivity1,
  841.             gTestLoLevelData.roomReflectivity1,
  842.             true);
  843.     
  844.     Utils_SetFloatField(
  845.             gTestLoLevelDialog,
  846.             kLoLevelItem_RoomReflectivity2,
  847.             gTestLoLevelData.roomReflectivity2,
  848.             gTestLoLevelData.roomReflectivityRange);
  849.     
  850.     Utils_SetFloatField(
  851.             gTestLoLevelDialog,
  852.             kLoLevelItem_ReverbAttenuation1,
  853.             gTestLoLevelData.reverbAttenuation1,
  854.             true);
  855.     
  856.     Utils_SetFloatField(
  857.             gTestLoLevelDialog,
  858.             kLoLevelItem_ReverbAttenuation2,
  859.             gTestLoLevelData.reverbAttenuation2,
  860.             gTestLoLevelData.reverbAttenuationRange);
  861.     
  862.     value = kSourceModeItem_Unfiltered;
  863.     switch (gTestLoLevelData.sourceMode)
  864.     {
  865.         case kSSpSourceMode_Localized:
  866.             value = kSourceModeItem_Localized;
  867.         break;
  868.         
  869.         case kSSpSourceMode_Ambient:
  870.             value = kSourceModeItem_Ambient;
  871.         break;
  872.         
  873.         case kSSpSourceMode_Binaural:
  874.             value = kSourceModeItem_Binaural;
  875.         break;
  876.     }
  877.     
  878.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_SourceMode, &itemType, &itemHandle, &itemBounds);
  879.     SetControlValue((ControlHandle) itemHandle, value);
  880.     
  881.     Utils_SetFloatField(
  882.             gTestLoLevelDialog,
  883.             kLoLevelItem_ReferenceDistance1,
  884.             gTestLoLevelData.referenceDistance1,
  885.             true);
  886.     
  887.     Utils_SetFloatField(
  888.             gTestLoLevelDialog,
  889.             kLoLevelItem_ReferenceDistance2,
  890.             gTestLoLevelData.referenceDistance2,
  891.             gTestLoLevelData.referenceDistanceRange);
  892.     
  893.     Utils_SetFloatField(
  894.             gTestLoLevelDialog,
  895.             kLoLevelItem_ConeAngleDeg1,
  896.             gTestLoLevelData.coneAngleDeg1,
  897.             true);
  898.     
  899.     Utils_SetFloatField(
  900.             gTestLoLevelDialog,
  901.             kLoLevelItem_ConeAngleDeg2,
  902.             gTestLoLevelData.coneAngleDeg2,
  903.             gTestLoLevelData.coneAngleDegRange);
  904.     
  905.     Utils_SetFloatField(
  906.             gTestLoLevelDialog,
  907.             kLoLevelItem_ConeAttenuation1,
  908.             gTestLoLevelData.coneAttenuation1,
  909.             true);
  910.     
  911.     Utils_SetFloatField(
  912.             gTestLoLevelDialog,
  913.             kLoLevelItem_ConeAttenuation2,
  914.             gTestLoLevelData.coneAttenuation2,
  915.             gTestLoLevelData.coneAttenuationRange);
  916.     
  917.     Utils_SetFloatField(
  918.             gTestLoLevelDialog,
  919.             kLoLevelItem_ElevationDeg1,
  920.             gTestLoLevelData.elevationDeg1,
  921.             true);
  922.     
  923.     Utils_SetFloatField(
  924.             gTestLoLevelDialog,
  925.             kLoLevelItem_ElevationDeg2,
  926.             gTestLoLevelData.elevationDeg2,
  927.             gTestLoLevelData.elevationDegRange);
  928.     
  929.     Utils_SetFloatField(
  930.             gTestLoLevelDialog,
  931.             kLoLevelItem_AzimuthDeg1,
  932.             gTestLoLevelData.azimuthDeg1,
  933.             true);
  934.     
  935.     Utils_SetFloatField(
  936.             gTestLoLevelDialog,
  937.             kLoLevelItem_AzimuthDeg2,
  938.             gTestLoLevelData.azimuthDeg2,
  939.             gTestLoLevelData.azimuthDegRange);
  940.     
  941.     Utils_SetFloatField(
  942.             gTestLoLevelDialog,
  943.             kLoLevelItem_Distance1,
  944.             gTestLoLevelData.distance1,
  945.             true);
  946.     
  947.     Utils_SetFloatField(
  948.             gTestLoLevelDialog,
  949.             kLoLevelItem_Distance2,
  950.             gTestLoLevelData.distance2,
  951.             gTestLoLevelData.distanceRange);
  952.     
  953.     Utils_SetFloatField(
  954.             gTestLoLevelDialog,
  955.             kLoLevelItem_ProjectionAngleDeg1,
  956.             gTestLoLevelData.projectionAngleDeg1,
  957.             true);
  958.     
  959.     Utils_SetFloatField(
  960.             gTestLoLevelDialog,
  961.             kLoLevelItem_ProjectionAngleDeg2,
  962.             gTestLoLevelData.projectionAngleDeg2,
  963.             gTestLoLevelData.projectionAngleDegRange);
  964.     
  965.     Utils_SetFloatField(
  966.             gTestLoLevelDialog,
  967.             kLoLevelItem_SourceVelocity1,
  968.             gTestLoLevelData.sourceVelocity1,
  969.             true);
  970.     
  971.     Utils_SetFloatField(
  972.             gTestLoLevelDialog,
  973.             kLoLevelItem_SourceVelocity2,
  974.             gTestLoLevelData.sourceVelocity2,
  975.             gTestLoLevelData.sourceVelocityRange);
  976.     
  977.     Utils_SetFloatField(
  978.             gTestLoLevelDialog,
  979.             kLoLevelItem_ListenerVelocity1,
  980.             gTestLoLevelData.listenerVelocity1,
  981.             true);
  982.     
  983.     Utils_SetFloatField(
  984.             gTestLoLevelDialog,
  985.             kLoLevelItem_ListenerVelocity2,
  986.             gTestLoLevelData.listenerVelocity2,
  987.             gTestLoLevelData.listenerVelocityRange);
  988. }
  989.  
  990.  
  991. /* =============================================================================
  992.  *        TestLoLevel_GetDialogFields (internal)
  993.  *
  994.  *    Grabs the contents of the dialog fields and puts them into gTestLoLevelData.
  995.  * ========================================================================== */
  996. void TestLoLevel_GetDialogFields(
  997.     void)
  998. {
  999.     const float            small = 0.000001;
  1000.     const float            big = 10000000.0;
  1001.     short                itemType;
  1002.     Handle                itemHandle;
  1003.     Rect                itemBounds;
  1004.     TTestLoLevelData    data;
  1005.     short                badItem;
  1006.     
  1007.     if (!Utils_GetFloatField(
  1008.             gTestLoLevelDialog,
  1009.             kLoLevelItem_Duration,
  1010.             &data.duration,
  1011.             NULL,
  1012.             small,
  1013.             big))
  1014.     {
  1015.         badItem = kLoLevelItem_Duration;
  1016.         goto bail;
  1017.     }
  1018.     
  1019.     if (!Utils_GetUInt32Field(
  1020.             gTestLoLevelDialog,
  1021.             kLoLevelItem_CPULoad1,
  1022.             &data.cpuLoad1,
  1023.             NULL,
  1024.             0,
  1025.             gTestLoLevelCPULoadLimit))
  1026.     {
  1027.         badItem = kLoLevelItem_CPULoad1;
  1028.         goto bail;
  1029.     }
  1030.     
  1031.     if (!Utils_GetUInt32Field(
  1032.             gTestLoLevelDialog,
  1033.             kLoLevelItem_CPULoad2,
  1034.             &data.cpuLoad2,
  1035.             &data.cpuLoadRange,
  1036.             0,
  1037.             gTestLoLevelCPULoadLimit))
  1038.     {
  1039.         badItem = kLoLevelItem_CPULoad2;
  1040.         goto bail;
  1041.     }
  1042.     
  1043.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_Medium, &itemType, &itemHandle, &itemBounds);
  1044.     switch (GetControlValue((ControlHandle) itemHandle))
  1045.     {
  1046.         case kMediumItem_Air:
  1047.             data.medium = kSSpMedium_Air;
  1048.         break;
  1049.         
  1050.         case kMediumItem_Water:
  1051.             data.medium = kSSpMedium_Water;
  1052.         break;
  1053.         
  1054.         default:
  1055.             assert(0);
  1056.     }
  1057.     
  1058.     if (!Utils_GetFloatField(
  1059.             gTestLoLevelDialog,
  1060.             kLoLevelItem_Humidity1,
  1061.             &data.humidity1,
  1062.             NULL,
  1063.             0.0,
  1064.             100.0))
  1065.     {
  1066.         badItem = kLoLevelItem_Humidity1;
  1067.         goto bail;
  1068.     }
  1069.     
  1070.     if (!Utils_GetFloatField(
  1071.             gTestLoLevelDialog,
  1072.             kLoLevelItem_Humidity2,
  1073.             &data.humidity2,
  1074.             &data.humidityRange,
  1075.             0.0,
  1076.             100.0))
  1077.     {
  1078.         badItem = kLoLevelItem_Humidity2;
  1079.         goto bail;
  1080.     }
  1081.     
  1082.     if (!Utils_GetFloatField(
  1083.             gTestLoLevelDialog,
  1084.             kLoLevelItem_RoomSize1,
  1085.             &data.roomSize1,
  1086.             NULL,
  1087.             0.0,
  1088.             big))
  1089.     {
  1090.         badItem = kLoLevelItem_RoomSize1;
  1091.         goto bail;
  1092.     }
  1093.     
  1094.     if (!Utils_GetFloatField(
  1095.             gTestLoLevelDialog,
  1096.             kLoLevelItem_RoomSize2,
  1097.             &data.roomSize2,
  1098.             &data.roomSizeRange,
  1099.             0.0,
  1100.             big))
  1101.     {
  1102.         badItem = kLoLevelItem_RoomSize2;
  1103.         goto bail;
  1104.     }
  1105.     
  1106.     if (!Utils_GetFloatField(
  1107.             gTestLoLevelDialog,
  1108.             kLoLevelItem_RoomReflectivity1,
  1109.             &data.roomReflectivity1,
  1110.             NULL,
  1111.             -big,
  1112.             -small))
  1113.     {
  1114.         badItem = kLoLevelItem_RoomReflectivity1;
  1115.         goto bail;
  1116.     }
  1117.     
  1118.     if (!Utils_GetFloatField(
  1119.             gTestLoLevelDialog,
  1120.             kLoLevelItem_RoomReflectivity2,
  1121.             &data.roomReflectivity2,
  1122.             &data.roomReflectivityRange,
  1123.             -big,
  1124.             -small))
  1125.     {
  1126.         badItem = kLoLevelItem_RoomReflectivity2;
  1127.         goto bail;
  1128.     }
  1129.     
  1130.     if (!Utils_GetFloatField(
  1131.             gTestLoLevelDialog,
  1132.             kLoLevelItem_ReverbAttenuation1,
  1133.             &data.reverbAttenuation1,
  1134.             NULL,
  1135.             -big,
  1136.             big))
  1137.     {
  1138.         badItem = kLoLevelItem_ReverbAttenuation1;
  1139.         goto bail;
  1140.     }
  1141.     
  1142.     if (!Utils_GetFloatField(
  1143.             gTestLoLevelDialog,
  1144.             kLoLevelItem_ReverbAttenuation2,
  1145.             &data.reverbAttenuation2,
  1146.             &data.reverbAttenuationRange,
  1147.             -big,
  1148.             big))
  1149.     {
  1150.         badItem = kLoLevelItem_ReverbAttenuation2;
  1151.         goto bail;
  1152.     }
  1153.     
  1154.     GetDialogItem(gTestLoLevelDialog, kLoLevelItem_SourceMode, &itemType, &itemHandle, &itemBounds);
  1155.     switch (GetControlValue((ControlHandle) itemHandle))
  1156.     {
  1157.         case kSourceModeItem_Unfiltered:
  1158.             data.sourceMode = kSSpSourceMode_Unfiltered;
  1159.         break;
  1160.         
  1161.         case kSourceModeItem_Localized:
  1162.             data.sourceMode = kSSpSourceMode_Localized;
  1163.         break;
  1164.         
  1165.         case kSourceModeItem_Ambient:
  1166.             data.sourceMode = kSSpSourceMode_Ambient;
  1167.         break;
  1168.         
  1169.         case kSourceModeItem_Binaural:
  1170.             data.sourceMode = kSSpSourceMode_Binaural;
  1171.         break;
  1172.         
  1173.         default:
  1174.             assert(0);
  1175.     }
  1176.     
  1177.     if (!Utils_GetFloatField(
  1178.             gTestLoLevelDialog,
  1179.             kLoLevelItem_ReferenceDistance1,
  1180.             &data.referenceDistance1,
  1181.             NULL,
  1182.             small,
  1183.             big))
  1184.     {
  1185.         badItem = kLoLevelItem_ReferenceDistance1;
  1186.         goto bail;
  1187.     }
  1188.     
  1189.     if (!Utils_GetFloatField(
  1190.             gTestLoLevelDialog,
  1191.             kLoLevelItem_ReferenceDistance2,
  1192.             &data.referenceDistance2,
  1193.             &data.referenceDistanceRange,
  1194.             small,
  1195.             big))
  1196.     {
  1197.         badItem = kLoLevelItem_ReferenceDistance2;
  1198.         goto bail;
  1199.     }
  1200.     
  1201.     if (!Utils_GetFloatField(
  1202.             gTestLoLevelDialog,
  1203.             kLoLevelItem_ConeAngleDeg1,
  1204.             &data.coneAngleDeg1,
  1205.             NULL,
  1206.             0.0,
  1207.             360.0))
  1208.     {
  1209.         badItem = kLoLevelItem_ConeAngleDeg1;
  1210.         goto bail;
  1211.     }
  1212.     
  1213.     if (!Utils_GetFloatField(
  1214.             gTestLoLevelDialog,
  1215.             kLoLevelItem_ConeAngleDeg2,
  1216.             &data.coneAngleDeg2,
  1217.             &data.coneAngleDegRange,
  1218.             0.0,
  1219.             360.0))
  1220.     {
  1221.         badItem = kLoLevelItem_ConeAngleDeg2;
  1222.         goto bail;
  1223.     }
  1224.     
  1225.     if (!Utils_GetFloatField(
  1226.             gTestLoLevelDialog,
  1227.             kLoLevelItem_ConeAttenuation1,
  1228.             &data.coneAttenuation1,
  1229.             NULL,
  1230.             -big,
  1231.             big))
  1232.     {
  1233.         badItem = kLoLevelItem_ConeAttenuation1;
  1234.         goto bail;
  1235.     }
  1236.     
  1237.     if (!Utils_GetFloatField(
  1238.             gTestLoLevelDialog,
  1239.             kLoLevelItem_ConeAttenuation2,
  1240.             &data.coneAttenuation2,
  1241.             &data.coneAttenuationRange,
  1242.             -big,
  1243.             big))
  1244.     {
  1245.         badItem = kLoLevelItem_ConeAttenuation2;
  1246.         goto bail;
  1247.     }
  1248.     
  1249.     if (!Utils_GetFloatField(
  1250.             gTestLoLevelDialog,
  1251.             kLoLevelItem_ElevationDeg1,
  1252.             &data.elevationDeg1,
  1253.             NULL,
  1254.             -big,
  1255.             big))
  1256.     {
  1257.         badItem = kLoLevelItem_ElevationDeg1;
  1258.         goto bail;
  1259.     }
  1260.     
  1261.     if (!Utils_GetFloatField(
  1262.             gTestLoLevelDialog,
  1263.             kLoLevelItem_ElevationDeg2,
  1264.             &data.elevationDeg2,
  1265.             &data.elevationDegRange,
  1266.             -big,
  1267.             big))
  1268.     {
  1269.         badItem = kLoLevelItem_ElevationDeg2;
  1270.         goto bail;
  1271.     }
  1272.     
  1273.     
  1274.     if (!Utils_GetFloatField(
  1275.             gTestLoLevelDialog,
  1276.             kLoLevelItem_AzimuthDeg1,
  1277.             &data.azimuthDeg1,
  1278.             NULL,
  1279.             -big,
  1280.             big))
  1281.     {
  1282.         badItem = kLoLevelItem_AzimuthDeg1;
  1283.         goto bail;
  1284.     }
  1285.     
  1286.     if (!Utils_GetFloatField(
  1287.             gTestLoLevelDialog,
  1288.             kLoLevelItem_AzimuthDeg2,
  1289.             &data.azimuthDeg2,
  1290.             &data.azimuthDegRange,
  1291.             -big,
  1292.             big))
  1293.     {
  1294.         badItem = kLoLevelItem_AzimuthDeg2;
  1295.         goto bail;
  1296.     }
  1297.     
  1298.     if (!Utils_GetFloatField(
  1299.             gTestLoLevelDialog,
  1300.             kLoLevelItem_Distance1,
  1301.             &data.distance1,
  1302.             NULL,
  1303.             small,
  1304.             big))
  1305.     {
  1306.         badItem = kLoLevelItem_Distance1;
  1307.         goto bail;
  1308.     }
  1309.     
  1310.     if (!Utils_GetFloatField(
  1311.             gTestLoLevelDialog,
  1312.             kLoLevelItem_Distance2,
  1313.             &data.distance2,
  1314.             &data.distanceRange,
  1315.             small,
  1316.             big))
  1317.     {
  1318.         badItem = kLoLevelItem_Distance2;
  1319.         goto bail;
  1320.     }
  1321.     
  1322.     if (!Utils_GetFloatField(
  1323.             gTestLoLevelDialog,
  1324.             kLoLevelItem_ProjectionAngleDeg1,
  1325.             &data.projectionAngleDeg1,
  1326.             NULL,
  1327.             0.0,
  1328.             180.0))
  1329.     {
  1330.         badItem = kLoLevelItem_ProjectionAngleDeg1;
  1331.         goto bail;
  1332.     }
  1333.     
  1334.     if (!Utils_GetFloatField(
  1335.             gTestLoLevelDialog,
  1336.             kLoLevelItem_ProjectionAngleDeg2,
  1337.             &data.projectionAngleDeg2,
  1338.             &data.projectionAngleDegRange,
  1339.             0.0,
  1340.             180.0))
  1341.     {
  1342.         badItem = kLoLevelItem_ProjectionAngleDeg2;
  1343.         goto bail;
  1344.     }
  1345.     
  1346.     if (!Utils_GetFloatField(
  1347.             gTestLoLevelDialog,
  1348.             kLoLevelItem_SourceVelocity1,
  1349.             &data.sourceVelocity1,
  1350.             NULL,
  1351.             -big,
  1352.             big))
  1353.     {
  1354.         badItem = kLoLevelItem_SourceVelocity1;
  1355.         goto bail;
  1356.     }
  1357.     
  1358.     if (!Utils_GetFloatField(
  1359.             gTestLoLevelDialog,
  1360.             kLoLevelItem_SourceVelocity2,
  1361.             &data.sourceVelocity2,
  1362.             &data.sourceVelocityRange,
  1363.             -big,
  1364.             big))
  1365.     {
  1366.         badItem = kLoLevelItem_SourceVelocity2;
  1367.         goto bail;
  1368.     }
  1369.     
  1370.     if (!Utils_GetFloatField(
  1371.             gTestLoLevelDialog,
  1372.             kLoLevelItem_ListenerVelocity1,
  1373.             &data.listenerVelocity1,
  1374.             NULL,
  1375.             -big,
  1376.             big))
  1377.     {
  1378.         badItem = kLoLevelItem_ListenerVelocity1;
  1379.         goto bail;
  1380.     }
  1381.     
  1382.     if (!Utils_GetFloatField(
  1383.             gTestLoLevelDialog,
  1384.             kLoLevelItem_ListenerVelocity2,
  1385.             &data.listenerVelocity2,
  1386.             &data.listenerVelocityRange,
  1387.             -big,
  1388.             big))
  1389.     {
  1390.         badItem = kLoLevelItem_ListenerVelocity2;
  1391.         goto bail;
  1392.     }
  1393.     
  1394.     // All fields are good -- finish up
  1395.     gTestLoLevelData = data;
  1396.     TestLoLevel_DeriveData();
  1397.     
  1398.     TestLoLevel_SetDialogFields();
  1399.     
  1400.     return;
  1401.     
  1402.     // Error exit
  1403. bail:
  1404.     SelectDialogItemText(gTestLoLevelDialog, badItem, 0, 32767);
  1405.     StopAlert(kAlrtID_BadField, NULL);
  1406. }
  1407.  
  1408.  
  1409. /* =============================================================================
  1410.  *        TestLoLevel_Preset (external)
  1411.  *
  1412.  *    Updates the fields to the chosen preset value.
  1413.  * ========================================================================== */
  1414. void TestLoLevel_Preset(
  1415.     UInt32            index)
  1416. {
  1417.     TTestLoLevelData preset[] = {
  1418.         { /* nothing for index zero */ 0 },
  1419.         { /* Side-to-Side */
  1420.                 /* duration                */   4.0,
  1421.                 /* cpuLoad                */     0,     0, false,
  1422.                 /* medium                */ kSSpMedium_Air,
  1423.                 /* humidity                */   0.0,   0.0, false,
  1424.                 /* roomSize                */   0.0,   0.0, false,
  1425.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1426.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1427.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1428.                 /* referenceDistance    */   1.0,   0.0, false,
  1429.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1430.                 /* coneAttenuation        */   0.0,   0.0, false,
  1431.                 /* elevationDeg            */   0.0,   0.0, false,
  1432.                 /* azimuthDeg            */ -90.0,  90.0, true,
  1433.                 /* distance                */   1.0,   0.0, false,
  1434.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1435.                 /* sourceVelocity        */   0.0,   0.0, false,
  1436.                 /* listenerVelocity        */   0.0,   0.0, false
  1437.         },
  1438.         { /* dividing line */ 0 },
  1439.         { /* Ahead */
  1440.                 /* duration                */   4.0,
  1441.                 /* cpuLoad                */     0,     0, false,
  1442.                 /* medium                */ kSSpMedium_Air,
  1443.                 /* humidity                */   0.0,   0.0, false,
  1444.                 /* roomSize                */   0.0,   0.0, false,
  1445.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1446.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1447.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1448.                 /* referenceDistance    */   1.0,   0.0, false,
  1449.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1450.                 /* coneAttenuation        */   0.0,   0.0, false,
  1451.                 /* elevationDeg            */   0.0,   0.0, false,
  1452.                 /* azimuthDeg            */   0.0,   0.0, false,
  1453.                 /* distance                */   1.0,  10.0, true,
  1454.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1455.                 /* sourceVelocity        */   0.0,   0.0, false,
  1456.                 /* listenerVelocity        */   0.0,   0.0, false
  1457.         },
  1458.         { /* Ahead-Right */
  1459.                 /* duration                */   4.0,
  1460.                 /* cpuLoad                */     0,     0, false,
  1461.                 /* medium                */ kSSpMedium_Air,
  1462.                 /* humidity                */   0.0,   0.0, false,
  1463.                 /* roomSize                */   0.0,   0.0, false,
  1464.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1465.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1466.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1467.                 /* referenceDistance    */   1.0,   0.0, false,
  1468.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1469.                 /* coneAttenuation        */   0.0,   0.0, false,
  1470.                 /* elevationDeg            */   0.0,   0.0, false,
  1471.                 /* azimuthDeg            */  45.0,   0.0, false,
  1472.                 /* distance                */   1.0,  10.0, true,
  1473.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1474.                 /* sourceVelocity        */   0.0,   0.0, false,
  1475.                 /* listenerVelocity        */   0.0,   0.0, false
  1476.         },
  1477.         { /* Right */
  1478.                 /* duration                */   4.0,
  1479.                 /* cpuLoad                */     0,     0, false,
  1480.                 /* medium                */ kSSpMedium_Air,
  1481.                 /* humidity                */   0.0,   0.0, false,
  1482.                 /* roomSize                */   0.0,   0.0, false,
  1483.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1484.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1485.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1486.                 /* referenceDistance    */   1.0,   0.0, false,
  1487.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1488.                 /* coneAttenuation        */   0.0,   0.0, false,
  1489.                 /* elevationDeg            */   0.0,   0.0, false,
  1490.                 /* azimuthDeg            */  90.0,   0.0, false,
  1491.                 /* distance                */   1.0,  10.0, true,
  1492.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1493.                 /* sourceVelocity        */   0.0,   0.0, false,
  1494.                 /* listenerVelocity        */   0.0,   0.0, false
  1495.         },
  1496.         { /* Behind-Right */
  1497.                 /* duration                */   4.0,
  1498.                 /* cpuLoad                */     0,     0, false,
  1499.                 /* medium                */ kSSpMedium_Air,
  1500.                 /* humidity                */   0.0,   0.0, false,
  1501.                 /* roomSize                */   0.0,   0.0, false,
  1502.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1503.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1504.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1505.                 /* referenceDistance    */   1.0,   0.0, false,
  1506.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1507.                 /* coneAttenuation        */   0.0,   0.0, false,
  1508.                 /* elevationDeg            */ 180.0,   0.0, false,
  1509.                 /* azimuthDeg            */  45.0,   0.0, false,
  1510.                 /* distance                */   1.0,  10.0, true,
  1511.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1512.                 /* sourceVelocity        */   0.0,   0.0, false,
  1513.                 /* listenerVelocity        */   0.0,   0.0, false
  1514.         },
  1515.         { /* Behind */
  1516.                 /* duration                */   4.0,
  1517.                 /* cpuLoad                */     0,     0, false,
  1518.                 /* medium                */ kSSpMedium_Air,
  1519.                 /* humidity                */   0.0,   0.0, false,
  1520.                 /* roomSize                */   0.0,   0.0, false,
  1521.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1522.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1523.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1524.                 /* referenceDistance    */   1.0,   0.0, false,
  1525.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1526.                 /* coneAttenuation        */   0.0,   0.0, false,
  1527.                 /* elevationDeg            */ 180.0,   0.0, false,
  1528.                 /* azimuthDeg            */   0.0,   0.0, false,
  1529.                 /* distance                */   1.0,  10.0, true,
  1530.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1531.                 /* sourceVelocity        */   0.0,   0.0, false,
  1532.                 /* listenerVelocity        */   0.0,   0.0, false
  1533.         },
  1534.         { /* Behind-Left */
  1535.                 /* duration                */   4.0,
  1536.                 /* cpuLoad                */     0,     0, false,
  1537.                 /* medium                */ kSSpMedium_Air,
  1538.                 /* humidity                */   0.0,   0.0, false,
  1539.                 /* roomSize                */   0.0,   0.0, false,
  1540.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1541.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1542.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1543.                 /* referenceDistance    */   1.0,   0.0, false,
  1544.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1545.                 /* coneAttenuation        */   0.0,   0.0, false,
  1546.                 /* elevationDeg            */ 180.0,   0.0, false,
  1547.                 /* azimuthDeg            */ -45.0,   0.0, false,
  1548.                 /* distance                */   1.0,  10.0, true,
  1549.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1550.                 /* sourceVelocity        */   0.0,   0.0, false,
  1551.                 /* listenerVelocity        */   0.0,   0.0, false
  1552.         },
  1553.         { /* Left */
  1554.                 /* duration                */   4.0,
  1555.                 /* cpuLoad                */     0,     0, false,
  1556.                 /* medium                */ kSSpMedium_Air,
  1557.                 /* humidity                */   0.0,   0.0, false,
  1558.                 /* roomSize                */   0.0,   0.0, false,
  1559.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1560.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1561.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1562.                 /* referenceDistance    */   1.0,   0.0, false,
  1563.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1564.                 /* coneAttenuation        */   0.0,   0.0, false,
  1565.                 /* elevationDeg            */   0.0,   0.0, false,
  1566.                 /* azimuthDeg            */ -90.0,   0.0, false,
  1567.                 /* distance                */   1.0,  10.0, true,
  1568.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1569.                 /* sourceVelocity        */   0.0,   0.0, false,
  1570.                 /* listenerVelocity        */   0.0,   0.0, false
  1571.         },
  1572.         { /* Ahead-Left */
  1573.                 /* duration                */   4.0,
  1574.                 /* cpuLoad                */     0,     0, false,
  1575.                 /* medium                */ kSSpMedium_Air,
  1576.                 /* humidity                */   0.0,   0.0, false,
  1577.                 /* roomSize                */   0.0,   0.0, false,
  1578.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1579.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1580.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1581.                 /* referenceDistance    */   1.0,   0.0, false,
  1582.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1583.                 /* coneAttenuation        */   0.0,   0.0, false,
  1584.                 /* elevationDeg            */   0.0,   0.0, false,
  1585.                 /* azimuthDeg            */ -45.0,   0.0, false,
  1586.                 /* distance                */   1.0,  10.0, true,
  1587.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1588.                 /* sourceVelocity        */   0.0,   0.0, false,
  1589.                 /* listenerVelocity        */   0.0,   0.0, false
  1590.         },
  1591.         { /* dividing line */ 0 },
  1592.         { /* Around (1 meter) */
  1593.                 /* duration                */    4.0,
  1594.                 /* cpuLoad                */      0,     0, false,
  1595.                 /* medium                */  kSSpMedium_Air,
  1596.                 /* humidity                */    0.0,   0.0, false,
  1597.                 /* roomSize                */    0.0,   0.0, false,
  1598.                 /* roomReflectivity        */  -10.0,   0.0, false,
  1599.                 /* reverbAttenuation    */  -15.0,   0.0, false,
  1600.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1601.                 /* referenceDistance    */    1.0,   0.0, false,
  1602.                 /* coneAngleDeg            */   90.0,   0.0, false,
  1603.                 /* coneAttenuation        */    0.0,   0.0, false,
  1604.                 /* elevationDeg            */    0.0,   0.0, false,
  1605.                 /* azimuthDeg            */ -180.0, 180.0, true,
  1606.                 /* distance                */    1.0,   0.0, false,
  1607.                 /* projectionAngleDeg    */    0.0,   0.0, false,
  1608.                 /* sourceVelocity        */    0.0,   0.0, false,
  1609.                 /* listenerVelocity        */    0.0,   0.0, false
  1610.         },
  1611.         { /* Around (10 meters) */
  1612.                 /* duration                */    4.0,
  1613.                 /* cpuLoad                */      0,     0, false,
  1614.                 /* medium                */  kSSpMedium_Air,
  1615.                 /* humidity                */    0.0,   0.0, false,
  1616.                 /* roomSize                */    0.0,   0.0, false,
  1617.                 /* roomReflectivity        */  -10.0,   0.0, false,
  1618.                 /* reverbAttenuation    */  -15.0,   0.0, false,
  1619.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1620.                 /* referenceDistance    */    1.0,   0.0, false,
  1621.                 /* coneAngleDeg            */   90.0,   0.0, false,
  1622.                 /* coneAttenuation        */    0.0,   0.0, false,
  1623.                 /* elevationDeg            */    0.0,   0.0, false,
  1624.                 /* azimuthDeg            */ -180.0, 180.0, true,
  1625.                 /* distance                */   10.0,   0.0, false,
  1626.                 /* projectionAngleDeg    */    0.0,   0.0, false,
  1627.                 /* sourceVelocity        */    0.0,   0.0, false,
  1628.                 /* listenerVelocity        */    0.0,   0.0, false
  1629.         },
  1630.         { /* dividing line */ 0 },
  1631.         { /* Reverb — Living Room */
  1632.                 /* duration                */  10.0,
  1633.                 /* cpuLoad                */     0,     0, false,
  1634.                 /* medium                */ kSSpMedium_Air,
  1635.                 /* humidity                */   0.0,   0.0, false,
  1636.                 /* roomSize                */  10.0,   0.0, false,
  1637.                 /* roomReflectivity        */ -20.0,   0.0, false,
  1638.                 /* reverbAttenuation    */   0.0,   0.0, false,
  1639.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1640.                 /* referenceDistance    */   1.0,   0.0, false,
  1641.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1642.                 /* coneAttenuation        */   0.0,   0.0, false,
  1643.                 /* elevationDeg            */   0.0,   0.0, false,
  1644.                 /* azimuthDeg            */   0.0,   0.0, false,
  1645.                 /* distance                */   2.0,  10.0, true,
  1646.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1647.                 /* sourceVelocity        */   0.0,   0.0, false,
  1648.                 /* listenerVelocity        */   0.0,   0.0, false
  1649.         },
  1650.         { /* Reverb — Cave */
  1651.                 /* duration                */  10.0,
  1652.                 /* cpuLoad                */     0,     0, false,
  1653.                 /* medium                */ kSSpMedium_Air,
  1654.                 /* humidity                */   0.0,   0.0, false,
  1655.                 /* roomSize                */ 100.0,   0.0, false,
  1656.                 /* roomReflectivity        */ -40.0,   0.0, false,
  1657.                 /* reverbAttenuation    */  20.0,   0.0, false,
  1658.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1659.                 /* referenceDistance    */   1.0,   0.0, false,
  1660.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1661.                 /* coneAttenuation        */   0.0,   0.0, false,
  1662.                 /* elevationDeg            */   0.0,   0.0, false,
  1663.                 /* azimuthDeg            */   0.0,   0.0, false,
  1664.                 /* distance                */   2.0,  10.0, true,
  1665.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1666.                 /* sourceVelocity        */   0.0,   0.0, false,
  1667.                 /* listenerVelocity        */   0.0,   0.0, false
  1668.         },
  1669.         { /* Reverb — Stadium */
  1670.                 /* duration                */  10.0,
  1671.                 /* cpuLoad                */     0,     0, false,
  1672.                 /* medium                */ kSSpMedium_Air,
  1673.                 /* humidity                */   0.0,   0.0, false,
  1674.                 /* roomSize                */ 250.0,   0.0, false,
  1675.                 /* roomReflectivity        */ -15.0,   0.0, false,
  1676.                 /* reverbAttenuation    */  -5.0,   0.0, false,
  1677.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1678.                 /* referenceDistance    */   1.0,   0.0, false,
  1679.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1680.                 /* coneAttenuation        */   0.0,   0.0, false,
  1681.                 /* elevationDeg            */   0.0,   0.0, false,
  1682.                 /* azimuthDeg            */   0.0,   0.0, false,
  1683.                 /* distance                */   2.0,  10.0, true,
  1684.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1685.                 /* sourceVelocity        */   0.0,   0.0, false,
  1686.                 /* listenerVelocity        */   0.0,   0.0, false
  1687.         },
  1688.         { /* dividing line */ 0 },
  1689.         { /* Source Doppler */
  1690.                 /* duration                */   4.0,
  1691.                 /* cpuLoad                */     0,     0, false,
  1692.                 /* medium                */ kSSpMedium_Air,
  1693.                 /* humidity                */   0.0,   0.0, false,
  1694.                 /* roomSize                */   0.0,   0.0, false,
  1695.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1696.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1697.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1698.                 /* referenceDistance    */   1.0,   0.0, false,
  1699.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1700.                 /* coneAttenuation        */   0.0,   0.0, false,
  1701.                 /* elevationDeg            */   0.0,   0.0, false,
  1702.                 /* azimuthDeg            */   0.0,   0.0, false,
  1703.                 /* distance                */   1.0,   0.0, false,
  1704.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1705.                 /* sourceVelocity        */ -20.0,  20.0, true,
  1706.                 /* listenerVelocity        */   0.0,   0.0, false
  1707.         },
  1708.         { /* Listener Doppler */
  1709.                 /* duration                */   4.0,
  1710.                 /* cpuLoad                */     0,     0, false,
  1711.                 /* medium                */ kSSpMedium_Air,
  1712.                 /* humidity                */   0.0,   0.0, false,
  1713.                 /* roomSize                */   0.0,   0.0, false,
  1714.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1715.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1716.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1717.                 /* referenceDistance    */   1.0,   0.0, false,
  1718.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1719.                 /* coneAttenuation        */   0.0,   0.0, false,
  1720.                 /* elevationDeg            */   0.0,   0.0, false,
  1721.                 /* azimuthDeg            */   0.0,   0.0, false,
  1722.                 /* distance                */   1.0,   0.0, false,
  1723.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1724.                 /* sourceVelocity        */   0.0,   0.0, false,
  1725.                 /* listenerVelocity        */ -20.0,  20.0, true
  1726.         },
  1727.         { /* Combined Doppler */
  1728.                 /* duration                */   4.0,
  1729.                 /* cpuLoad                */     0,     0, false,
  1730.                 /* medium                */ kSSpMedium_Air,
  1731.                 /* humidity                */   0.0,   0.0, false,
  1732.                 /* roomSize                */   0.0,   0.0, false,
  1733.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1734.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1735.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1736.                 /* referenceDistance    */   1.0,   0.0, false,
  1737.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1738.                 /* coneAttenuation        */   0.0,   0.0, false,
  1739.                 /* elevationDeg            */   0.0,   0.0, false,
  1740.                 /* azimuthDeg            */   0.0,   0.0, false,
  1741.                 /* distance                */   1.0,   0.0, false,
  1742.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1743.                 /* sourceVelocity        */ -20.0,  20.0, true,
  1744.                 /* listenerVelocity        */ -20.0,  20.0, true
  1745.         },
  1746.         { /* Cancelled Doppler */
  1747.                 /* duration                */   4.0,
  1748.                 /* cpuLoad                */     0,     0, false,
  1749.                 /* medium                */ kSSpMedium_Air,
  1750.                 /* humidity                */   0.0,   0.0, false,
  1751.                 /* roomSize                */   0.0,   0.0, false,
  1752.                 /* roomReflectivity        */ -10.0,   0.0, false,
  1753.                 /* reverbAttenuation    */ -15.0,   0.0, false,
  1754.                 /* sourceMode            */ kSSpSourceMode_Localized,
  1755.                 /* referenceDistance    */   1.0,   0.0, false,
  1756.                 /* coneAngleDeg            */  90.0,   0.0, false,
  1757.                 /* coneAttenuation        */   0.0,   0.0, false,
  1758.                 /* elevationDeg            */   0.0,   0.0, false,
  1759.                 /* azimuthDeg            */   0.0,   0.0, false,
  1760.                 /* distance                */   1.0,   0.0, false,
  1761.                 /* projectionAngleDeg    */   0.0,   0.0, false,
  1762.                 /* sourceVelocity        */  20.0, -20.0, true,
  1763.                 /* listenerVelocity        */ -20.0,  20.0, true
  1764.         }
  1765.     };
  1766.     
  1767.     gTestLoLevelData = preset[index];
  1768.     
  1769.     TestLoLevel_DeriveData();
  1770.     TestLoLevel_SetDialogFields();
  1771. }
  1772.  
  1773.  
  1774.